package cn.schoolwow.workflow.test.module.oa.common.flow.common;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.Validate;

public class SetConvertWorkFlowNodeNameCommonFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        JSONObject childNode = flowContext.checkData("childNode", JSONObject.class);

        String name = childNode.getString("name");
        Validate.notNull(name, "节点名称不能为空");
        if(childNode.containsKey("usName")){
            name = name + "_" + childNode.getString("usName");
        }
        flowContext.putData("nodeName", name);
    }

    @Override
    public String name() {
        return "设置工作流节点名称公共流程";
    }
}
